import React from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
import { useEffect } from 'react'
function useRouter() {
    const nav = useNavigate()
    const { pathname } = useLocation()
    const token = localStorage.getItem('token')
    const list = ['/index/home']
    useEffect(() => {
        if (!token && !list.includes(pathname)) {
            nav('/login')
        }
    }, [])
}

export default useRouter
